package apps.softtech.fastmarket.model;

import android.content.ContentValues;
import android.database.Cursor;

public class Category {

	public static final String TABLE_NAME = "Category";
	public static final String ID = "id";
	public static final String CATEGORY_ID = "st_CategoryId";
	private int categoryId;

	public static final String CATEGORY_NAME = "st_CategoryName";
	private String categoryName;
	
	public static final String DESCRIPTION = "st_Description";
	private String category;

	public static final String PARENT_CATEGORY_ID = "st_ParentCategoryId";
	private int parentCategoryId;

	public static final String CATEGORY_LEVEL = "st_CategoryLevel";
	private int categoryLevel;

	

	public Category(String categoryName, String category, int parentCategoryId,
			int categoryLevel) {
		super();
		this.categoryName = categoryName;
		this.category = category;
		this.parentCategoryId = parentCategoryId;
		this.categoryLevel = categoryLevel;
	}

	public Category(int categoryId, String categoryName, String category,
			int parentCategoryId, int categoryLevel) {
		super();
		this.categoryId = categoryId;
		this.categoryName = categoryName;
		this.category = category;
		this.parentCategoryId = parentCategoryId;
		this.categoryLevel = categoryLevel;
	}

	public Category() {
		super();
		// TODO Auto-generated constructor stub
	}

	public int getCategoryId() {
		return categoryId;
	}

	public void setCategoryId(int categoryId) {
		this.categoryId = categoryId;
	}

	public String getCategoryName() {
		return categoryName;
	}

	public void setCategoryName(String categoryName) {
		this.categoryName = categoryName;
	}

	public String getCategory() {
		return category;
	}

	public void setCategory(String category) {
		this.category = category;
	}

	public int getParentCategoryId() {
		return parentCategoryId;
	}

	public void setParentCategoryId(int parentCategoryId) {
		this.parentCategoryId = parentCategoryId;
	}

	public int getCategoryLevel() {
		return categoryLevel;
	}

	public void setCategoryLevel(int categoryLevel) {
		this.categoryLevel = categoryLevel;
	}
	
	/**
	 * get value of Category
	 * @return
	 */
	public ContentValues getValueCategory(){
		ContentValues values = new ContentValues();
		values.put(DESCRIPTION, this.getCategory());
		values.put(CATEGORY_LEVEL, this.getCategoryLevel());
		values.put(CATEGORY_NAME, this.getCategoryName());
		values.put(PARENT_CATEGORY_ID, this.getParentCategoryId());
		
		return values;
	}

	public void setValueFromCursor(Cursor c) {
		Category category = new Category();
		
		if (c.getColumnIndex(CATEGORY_ID) >= 0) {
			setCategoryId(c.getInt(c.getColumnIndex(CATEGORY_ID)));
		}
		if (c.getColumnIndex(CATEGORY_NAME) >= 0) {
			setCategoryName(c.getString(c.getColumnIndex(CATEGORY_NAME)));
		}
		if (c.getColumnIndex(DESCRIPTION) >= 0) {
			setCategory(c.getString(c.getColumnIndex(DESCRIPTION)));
		}
		if (c.getColumnIndex(CATEGORY_LEVEL) >= 0) {
			setCategoryLevel(c.getInt(c.getColumnIndex(CATEGORY_LEVEL)));
		}
		if (c.getColumnIndex(PARENT_CATEGORY_ID) >= 0) {
			setParentCategoryId(c.getInt(c.getColumnIndex(PARENT_CATEGORY_ID)));
		}
		
	}

}
